package xjtu.se.articlecommunity.user.myarticle.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xjtu.se.articlecommunity.user.home.dto.QueueFeedDto;
import xjtu.se.articlecommunity.user.home.impl.HtmlHandler;
import xjtu.se.articlecommunity.user.myarticle.dao.MyartDao;
import xjtu.se.articlecommunity.user.myarticle.dto.MyartDto;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class MyarticleService {
    @Resource
    MyartDao myartDao;
    @Resource
    HtmlHandler htmlHandler;

    public List<MyartDto> getOwnArt(String u_id,String searchtxt,String ordertype){
        List<MyartDto> list = myartDao.getArtList(u_id,searchtxt,ordertype);
        String htmlStr = "";
        MyartDto dto = null;
        for(int i=0;i<list.size();i++){
            dto = list.get(i);
            dto.setImglist(htmlHandler.HtmlImgHandle(dto.getA_html()));
            dto.setA_html(htmlHandler.HtmlStrHandle(dto.getA_html()));
            list.set(i,dto);
        }
        return list;
    }
}
